/*
 * Accepter.h
 *
 *  Created on: 30/05/2011
 *      Author: dela
 */

#ifndef ACCEPTER_H_
#define ACCEPTER_H_

#include <list>
#include "common/Thread.h"
#include "common/Socket.h"
#include "common/Mutex.h"
#include "common/Socket.h"
#include "InstructorConnection.h"
#include "StudentConnection.h"

template <class T>
class Accepter : public Thread {
private:
	Socket socket;
	std::list<T*> connections;

	/**
	 * Elimina las conecciones que ya no estan en uso.
	 */
	void clearConnections();
protected:
	virtual void run();
public:
	Accepter( int port ) : socket(port) {};

	/**
	 * Detiene el accepter.
	 */
	void stop();
};

template class Accepter<InstructorConnection>;
template class Accepter<StudentConnection>;

#endif /* ACCEPTER_H_ */
